<!DOCTYPE html>
<html lang="zh-cn" xmlns:v-on="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
        <meta name="renderer" content="webkit">
        <title>修改信息</title>
        <link rel="stylesheet" href="/css/pintuer.css">
        <link rel="stylesheet" href="/css/admin.css">
        <script src="/js/jquery.js"></script>
        <script src="/js/pintuer.js"></script>
        <script src="/js/vue.js"></script>
        <script src="/js/axios.min.js"></script>
    </head>
    <body>
        <div class="panel admin-panel" id="updateInfo">
            <div class="panel-head"><strong><span class="icon-pencil-square-o"></span> 修改信息</strong></div>
            <div class="body-content">
                <form method="post" class="form-x" action="">
                    <div class="form-group">
                        <div class="label">
                            <label>管理员姓名：</label>
                        </div>
                        <div class="field">
                            <input type="text" class="input" name="stitle" id="adminName" value=""/>
                            <div class="tips"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="label">
                            <label>性别：</label>
                        </div>
                        <div class="field">
                            <div class="controls" id="adminSex">
                                <label data-toggle="radio" class="radio">
                                    <input type="radio" name="gender" value="男"/>
                                </label>
                                <label data-toggle="radio" class="radio">
                                    <input type="radio" name="gender" value="女"/>
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="label">
                            <label class="age">年龄：</label>
                        </div>
                        <div class="field">
                            <input type="text" class="input" name="surl" id="adminAge" value=""/>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="label">
                            <label></label>
                        </div>
                        <div class="field">
                            <button class="button bg-main icon-check-square-o" type="submit" v-on:click="updateInfo"> 提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <script>
            var vue = new Vue({
                el:"#updateInfo",
                data:{
                    adminId: "",
                    adminInfo:{}
                },
                methods:{
                    showId: function () {
                        let url = "/admin/showName";
                        axios.get(url)
                            .then(function (result) {
                                let adminId = result.data.adminId;
                                this.vue.adminId = adminId;
                            })
                            .catch();
                    },
                    updateInfo:function () {
                        let adminInfo = {
                            adminId:this.adminId,
                            adminName:$("#adminName").val(),
                            adminSex:$("input[name='gender']:checked").val(),
                            adminAge:$("#adminAge").val()
                        };
                        let url = "/admin/updateInfo";
                        axios.put(url,adminInfo)
                            .then(function (result) {
                                window.location.href = "info";
                            })
                            .catch();
                    },
                },
                mounted:function () {
                    this.showId();
                }
            })
        </script>
    </body>
</html>